﻿Public Class lavanderia
    Dim texto_lavado As String = "" '
    Dim texto_lavado_seco As String = ""
    Dim costo_lavado As Integer
    Dim costo_lavado1 As Integer
    Dim costo_planchado As Integer
    Dim texto_plachado As String = ""
    Dim TEXTO As String = ""
    Dim valor_teñido As Integer = 0
    Dim rs As ADODB.Recordset 'CREA UN OBJETO RS DE TIPO ADO PARA LA CONECCION
    Dim sql As String 'CREAMOS UN VALOR SQL DE TIPO CADENA PARA LOS DIFERENTES PROCESOS DE DATOS DE LA CONECCION DE LA BD (INSERTAR, SELECIONAR)

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
        GroupBox2.Enabled = False
    End Sub

    Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter
        GroupBox1.Enabled = False
    End Sub

    Private Sub lavanderia_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
        llenar(Resultado)
    End Sub
    Public Sub llenar(ByVal Resultado As String)
        sql = "SELECT CODI_CLIEN, NOMB_CLIEN, PATE_CLIEN, MATE_CLIEN  FROM CLIENTE WHERE (CODI_CLIEN = '" & Resultado & "')" 'SELECCIONAMOS LOS DATOS REQUERIDOS PARA CONSULTA USANDO LA TABLA CLIENTE
        'PERMITE SELECCIONAR LOS DATOS DE LA TABLA CLIENTE
        rs = coneccion.Execute(sql) 'PERMITE LA EJECUCION DE LA CONECCION
        'PERMITE EL RETORNO DE LOS VALOR DE LAS COLUMNAS(INDICE) DE LA TABLA CLIENTE
        txtNombre.Text = rs.Fields(1).Value
        txtPaterno.Text = rs.Fields(2).Value
        txtMaterno.Text = rs.Fields(3).Value
        txtCodigo.Text = rs.Fields(0).Value
    End Sub
    Private Sub Tintoreria_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conectar() 'PERMITE INICIALIZAR
        sql = "SELECT CONCEPTO, CODI_LAVAN FROM LAVANDERIA"
        rs = coneccion.Execute(sql)
        While rs.EOF <> True
            If rs.EOF = True Then
                Exit While
            End If
            If IsNumeric(rs.Fields(1).Value) Then
                ComboBox1.Items.Add(rs.Fields(0).Value.ToString)
            End If
            rs.MoveNext()
        End While
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        CheckBox2.Enabled = False 'ESTA INABILITADO
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & CheckBox1.Text & "')" 'SELECCIONAR LA TABLA LAVANDERIA  Y EL CAMPO CONCEPTO SEGUN LA SELECCION DEL CHECBOX1 
        rs = coneccion.Execute(sql) 'PERMITE JECUTAR LA CONECCION
        costo_planchado = CInt(rs.Fields(1).Value) 'RETORNA EL VALOR DEL COSTO SEGUN LA COLUMNA 1 DE LA TABLA LAVANDERIA
        texto_plachado = rs.Fields(0).Value
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        CheckBox1.Enabled = False 'ESTA INABILITADO
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & CheckBox2.Text & "')" 'SELECCIONAR LA TABLA LAVANDERIA  Y EL CAMPO CONCEPTO SEGUN LA SELECCION DEL CHECBOX2
        rs = coneccion.Execute(sql) 'PERMITE JECUTAR LA CONECCION
        costo_planchado = CInt(rs.Fields(1).Value) 'RETORNA EL VALOR DEL COSTO SEGUN LA COLUMNA 1 DE LA TABLA LAVANDERIA
        texto_plachado = rs.Fields(0).Value
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TEXTO = ComboBox1.SelectedItem.ToString
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & TEXTO & "')" 'SELECCIONAR LA TABLA LAVANDERIA  Y EL CAMPO CONCEPTO 
        rs = coneccion.Execute(sql) 'PERMITE JECUTAR LA CONECCION
        valor_teñido = CInt(rs.Fields(1).Value) 'RETORNA EL VALOR DEL TEÑIDO DE LA COLUMNA 1 DE LA TABLA CONCEPTO
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Select Case ComboBox2.SelectedIndex 'PERMITE SELECCIONAR LOS DIFERENTES CASSOS SEGUN LA CANTIDAD DE DATOS DEL COMBOBOX2(PAGO CON)
            Case 0
                PictureBox2.Load("din.jpg")
                PictureBox2.Show()
            Case 1
                PictureBox2.Load("tar.jpg")
                PictureBox2.Show()

            Case 2
                PictureBox2.Load("che.gif")
                PictureBox2.Show()
        End Select
    End Sub

    Private Sub btnFactura_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFactura.Click
        sql = "SELECT CODI_LAVAN,CONCEPTO FROM(lavanderia) WHERE (CONCEPTO = '" & texto_plachado & "')"
        rs = coneccion.Execute(sql)
        sql = "INSERT INTO [REGISTRO LAVANDERIA](CODI_LAVAN, FECHA_ENTREGA, FECHA_PEDIDO, CODI_CLIEN) VALUES ('" & rs.Fields(0).Value.ToString & "','" & Entrega.Value.ToString & "','" & Inicio.Value.ToString & "','" & txtCodigo.Text & "')"
        rs = coneccion.Execute(sql)
        Dispose()
        'Imprimir reporte
    End Sub

    Private Sub btnVerificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerificar.Click
        Dim mostrar As New Resultados(txtPaterno.Text, txtMaterno.Text, txtNombre.Text, txtCodigo.Text)
        mostrar.Show()
    End Sub

    Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click
        GroupBox2.Enabled = True
        GroupBox1.Enabled = True
        TextBox1.Text = ""
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton1.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado = CInt(rs.Fields(1).Value)
        texto_lavado = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton3.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado = CInt(rs.Fields(1).Value)
        texto_lavado = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton4.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado = CInt(rs.Fields(1).Value)
        texto_lavado = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton6.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado1 = CInt(rs.Fields(1).Value)
        texto_lavado_seco = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton7.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado1 = CInt(rs.Fields(1).Value)
        texto_lavado_seco = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged
        sql = "SELECT CONCEPTO, COSTO FROM(lavanderia) WHERE (CONCEPTO = '" & RadioButton8.Text & "')"
        rs = coneccion.Execute(sql)
        costo_lavado1 = CInt(rs.Fields(1).Value)
        texto_lavado_seco = " Seco " & rs.Fields(0).Value
    End Sub

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Entrega.ValueChanged
        TextBox1.Text = "CODIGO" & txtCodigo.Text & vbNewLine & txtPaterno.Text & vbNewLine & txtMaterno.Text & vbNewLine & txtNombre.Text & vbNewLine & texto_lavado & "  " & costo_lavado & vbNewLine & texto_lavado_seco & "  " & costo_lavado1 & vbNewLine & " " & texto_plachado & " " & costo_planchado & vbNewLine & TEXTO & "  " & valor_teñido

    End Sub

    Private Sub lavanderia_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        txtCosto.Text = (costo_lavado + costo_lavado1 + costo_planchado + valor_teñido).ToString
        txtIgv.Text = CDbl(txtCosto.Text) * 0.19
        txtTotal.Text = CDbl(txtCosto.Text) * 1.19
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtCodigo.Text = ""
        txtPaterno.Text = ""
        txtMaterno.Text = ""
        txtNombre.Text = ""
    End Sub
End Class
